using System;
using System.Collections.ObjectModel;
using System.Web.UI;

namespace Controls
{
    /// <summary>
    /// Defines a split part of the complete page load which would be invoked 
    /// synchronously.
    /// </summary>
    /// <author>Atanu Podder</author>
    public class SplitItem : SequenceItem
    {
        /// <summary>
        /// Occurs when the <see cref="SplitItem"/> is ready for invokation of loading method.
        /// </summary>
        public event EventHandler ItemSequenced;

        /// <summary>
        /// Inovkes the the loading method synchronously. See <see cref="SequenceItem.LoadUpdatePanel"/>.
        /// </summary>
        /// <param name="inProgressSequenceItems"><see cref="SequenceItem"/>s which have initiated the load process
        /// and not completed the loading.</param>
        protected internal override void LoadUpdatePanel(Collection<SequenceItem> inProgressSequenceItems)
        {
            ItemSequenced(this, EventArgs.Empty);
            if (UpdatePanel.UpdateMode == UpdatePanelUpdateMode.Conditional)
            {
                UpdatePanel.Update();
            }
            HasLoaded = true;
        }

        /// <summary>
        /// See <see cref="SequenceItem.HasLoadCompleted"/>.
        /// </summary>
        protected internal override bool HasLoadCompleted()
        {
            return HasLoaded;
        }

    }
}

